﻿using UnityEngine;
using UnityEngine.UI;
using System.Collections;

public class Overhead : MonoBehaviour
{
	public Text names;
	public Slider health_Slider;
	public GameObject damge_text_perfab;
	// Use this for initialization
	void Start (){
	
	}
	
	// Update is called once per frame
	void Update () {
	
	}
	public void ini(string name, float health, float height)
	{
		names.text = name;
		health_Slider.maxValue = health;
		health_Slider.value = health;
		transform.position += new Vector3(0,height,0);  

	}
	public void hited(Damage damge)
	{
		health_Slider.value -= damge.Hurt;
		//health_Slider.value = Mathf.Clamp(health_Slider.value, 0, health_Slider.maxValue);
		GameObject dmg_text = Instantiate(damge_text_perfab);
		dmg_text.transform.SetParent(transform,false);
		dmg_text.GetComponent<Dmg_text>().ini(damge.Hurt,damge.Crit);
	}
}
